<?php
/**
 * Course Class Model
 *
 * Copyright 2012
 * @date 21-April-2012
 * @author 
 * @version 0.0.1
 **/
class Country extends AppModel {
/**
 * Name
 *
 * @var string
 */
    public $name = 'Country';
    public $hasMany = array(
        'City' => array(
              'className' => 'City',
              'foreignKey' => 'country_id'
        )
    );
    public function get_list(){
        $country_list = $this->find('list',array('fields'=>array('name')));
        return $country_list;
    }
    public static function get_name($id){
        $country = ClassRegistry::init('Country');
        $country->id = $id;
        return $country->field('name');
    }
    public function check_exist($name){
        $country = $this->find('first',array('conditions'=>array('name'=>$name)));
        if(!empty($country)){
            return $country['Country']['id'];
        }
        return 0;
    }
}